﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SalesSys.Comm.Utility;
using SalesSys.WebCore;
using SalesSys.WebCore.Authorize;

namespace SalesSys.Site.Controllers
{
    public class HomeController : BaseController
    {
       
        public ActionResult Index()
        {
            return RedirectToAction("Login");
            //return View("Login");
        }


        [HttpPost]
        public ActionResult Login(string loginName,string md5Pw,string salt)
        {
            var s = ClientHelper.UserLoginAuth(HttpContext, loginName, md5Pw, salt);
           // ClientHelper.SetUserLogin(HttpContext,new Employee());
            if (s)
            {
                 return Redirect(Url.Action("Index","NoticeInfo"));
            }
            ReHandleState(ReState.Unauthorized, "错误的账户名密码！");
            return View();
        }

        public ActionResult Login()
        {
            //if ( ClientHelper.ClientInfo != null)
            //{
            //    return Redirect("/htm/index.html#/app/News/news");                
            //}
            ViewBag.sale = Guid.NewGuid().ToString();
            return View();
        }

        public ActionResult Logout()
        {  
            if (ClientHelper.ClientInfo!=null)
            {
                  ZhdMsgHub.RemoveUser(ClientHelper.ClientInfo.Id);
            }
            ClientHelper.OutLogin();
          
          
            return RedirectToAction("Login");
        }
    }
}
